package com.wonderplay.warlord.module.story;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.KeyEvent;
import android.view.MotionEvent;

import com.wonderplay.engine.GameEngine;
import com.wonderplay.engine.LogicEngine;
import com.wonderplay.engine.ModuleChangeMessage;
import com.wonderplay.warlord.conf.WarLordConf;
import com.wonderplay.warlord.conf.WarLordContants;
import com.wonderplay.warlord.engine.CharacterStatus;

public class WarLordStoryLogicEngine extends LogicEngine{
	
	int nextModule = WarLordContants.MODULE_STORY;
	
	/**************for test**************/
	public CharacterStatus playerCharStatus;
	public CharacterStatus opponentCharStatus;
	/**************for test**************/
	
	public WarLordStoryLogicEngine(GameEngine gameEngine, int moduleId){
		super(gameEngine, moduleId);
		
		//TODO remove test code
		/**************for test**************/
		int elementTypeNum = WarLordConf.getTypes() - 1;
		int[] maxElementPlayer = new int[elementTypeNum];
		int[] maxElementOpponent = new int[elementTypeNum];
		for (int i=0; i<elementTypeNum; i++){
			maxElementPlayer[i] = 20;
			maxElementOpponent[i] = 20;
		}
		
		playerCharStatus = new CharacterStatus(200, maxElementPlayer);
		opponentCharStatus = new CharacterStatus(200, maxElementOpponent);

		/**************for test**************/
	}
	
	@Override
	public void drawCanvas(Canvas canvas) {
		// TODO Auto-generated method stub
		canvas.save();
		canvas.drawColor(Color.WHITE);
		canvas.drawText("test", 0, 20, new Paint());
		canvas.restore();
	}

	@Override
	public void performKeyEvent(KeyEvent keyEvent) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void performTouchEvent(MotionEvent touchEvent) {
		switch (touchEvent.getAction()) {
		case MotionEvent.ACTION_DOWN:
			
			//or should call it onModuleEnd??
			moduleChangeNotifier.setMessage(WarLordContants.MODULE_COMBAT, new StoryCombatChangeMessage());
			break;
		default:
			break;
		}
	}

	@Override
	public void reset() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void updateLogic() {
		
	}
	
}

class StoryCombatChangeMessage implements ModuleChangeMessage{
	
}
